﻿using System.Windows.Forms;

namespace Voize
{
    internal class CAppInstance
    {


        internal CAppInstance(ref string[] args)
        {
            m_Arguments = args;
        }



        private string[] m_Arguments;



        internal void Init()
        {

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
            fPlayer PlayerInstance = null;

            if (m_Arguments.Length > 0)
            {
                if (m_Arguments[0].EndsWith(".voize") || m_Arguments[0].EndsWith(".m3u"))
                {
                    string root = "";

                    if (m_Arguments[0].EndsWith(".m3u"))
                    {
                        root = System.IO.Path.GetDirectoryName(m_Arguments[0]);
                        root += @"\";
                    }
                    PlayerInstance = new fPlayer(m_Arguments[0],root);
                }

                
                if(m_Arguments[0].EndsWith(".mp3") 
                    || m_Arguments[0].EndsWith(".ogg")
                     || m_Arguments[0].EndsWith(".flac")
                    || m_Arguments[0].EndsWith(".s3m")
                    || m_Arguments[0].EndsWith(".mod")
                    || m_Arguments[0].EndsWith(".xm")
                    || m_Arguments[0].EndsWith(".wav")
                    )
                {
                    PlayerInstance = new fPlayer(m_Arguments[0]);
                }

            }
            else
            {
                PlayerInstance = new fPlayer();
                
            }
            Application.Run(PlayerInstance);
        }



    }
}
